// 商家下拉列表
import { GetMerchantInfoList } from "@/request/merchantinfo"
import { useEffect, useState } from "react"

export default function useMerchant () {
    const [ options, setOptions ] = useState<Array<Record<string,unknown>>>([])
    const getData = async () => {
        const { code, data } = await GetMerchantInfoList({limit: 1000, page: 1} as any)
        if ( code === 200 ) {
            setOptions( data.list?.map((item: { fullName: any; id: any })=>{
                return {
                    ...item,
                    label:item.fullName,
                    value:item.id
                }
            }) )
        } else {
            setOptions( [] )
        }
    }
    useEffect( () => {
        getData()
    }, [] )
    return options
}